package com.wbs.shop.nuby.view.fragment;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wbs.shop.nuby.utils.Logger;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by zhoucl on 2018/5/21 0021.
 */
public abstract class BaseFragment extends Fragment {
    Unbinder bind;
    protected View mView;

    protected abstract int tellMeLayout();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        try {
            if (tellMeLayout() != 0) {
                mView = inflater.inflate(tellMeLayout(), null);
            } else {
                mView = super.onCreateView(inflater, container, savedInstanceState);
            }
            bind = ButterKnife.bind(this, mView);
            init(mView, savedInstanceState);
        } catch (Exception e) {
            Logger.e(e);
        }
        return mView;
    }

    protected void init(View view, Bundle savedInstanceState) {

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (bind != null) {
            bind.unbind();
        }
    }
}
